﻿using System.Collections.ObjectModel;
using AvaloniaApplication1.Models;
using AvaloniaApplication1.Models.DTOModel;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;

namespace AvaloniaApplication1.ViewModels.ModbusCardViewModel;

public partial class UpdateSlaveDataPointViewModel:ObservableObject
{
    [ObservableProperty]
    private string _deviceName;
    [ObservableProperty]
    private SlaveInfo _slaveInfo;
    /// <summary>
    /// 数据点列表
    /// </summary>
    [ObservableProperty]
    private ObservableCollection<RegisterDataPoints> _dataPointsList;
    
    public UpdateSlaveDataPointViewModel(string deviceName,SlaveInfo slaveInfo)
    {
        DeviceName = deviceName;
        SlaveInfo = slaveInfo;
        DataPointsList = slaveInfo.DataPoints;
    }

    [RelayCommand]
    private void SaveCommand()
    {
        SlaveInfo.DataPoints = DataPointsList;
    }
}